package com.rfid.web.controller.system;

import java.util.List;

import com.rfid.system.domain.TItemInfo;
import com.rfid.system.domain.TProductInfo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.rfid.common.annotation.Log;
import com.rfid.common.enums.BusinessType;
import com.rfid.system.domain.TRfidAuditTotal;
import com.rfid.system.service.ITRfidAuditTotalService;
import com.rfid.common.core.controller.BaseController;
import com.rfid.common.core.domain.AjaxResult;
import com.rfid.common.utils.poi.ExcelUtil;
import com.rfid.common.core.page.TableDataInfo;

/**
 * 稽查总Controller
 *
 * @author fangchen
 * @date 2021-01-13
 */
@Controller
@RequestMapping("/system/auditTotal")
public class TRfidAuditTotalController extends BaseController {
    private String prefix = "system/auditTotal";

    @Autowired
    private ITRfidAuditTotalService tRfidAuditTotalService;

    @RequiresPermissions("system:total:view")
    @GetMapping()
    public String total() {
        return prefix + "/audittotal";
    }

    /**
     * 查询稽查总列表
     */
    @RequiresPermissions("system:total:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TRfidAuditTotal tRfidAuditTotal) {
        startPage();
        List<TRfidAuditTotal> list = tRfidAuditTotalService.selectTRfidAuditTotalList(tRfidAuditTotal);
        return getDataTable(list);
    }

    /**
     * 导出稽查总列表
     */
    @RequiresPermissions("system:total:export")
    @Log(title = "稽查总", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TRfidAuditTotal tRfidAuditTotal) {
        List<TRfidAuditTotal> list = tRfidAuditTotalService.selectTRfidAuditTotalList(tRfidAuditTotal);
        ExcelUtil<TRfidAuditTotal> util = new ExcelUtil<TRfidAuditTotal>(TRfidAuditTotal.class);
        return util.exportExcel(list, "total");
    }

    /**
     * 新增稽查总
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增保存稽查总
     */
    @RequiresPermissions("system:total:add")
    @Log(title = "稽查总", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TRfidAuditTotal tRfidAuditTotal) {
        return toAjax(tRfidAuditTotalService.insertTRfidAuditTotal(tRfidAuditTotal));
    }

    /**
     * 修改稽查总
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap) {
        TRfidAuditTotal tRfidAuditTotal = tRfidAuditTotalService.selectTRfidAuditTotalById(id);
        mmap.put("tRfidAuditTotal", tRfidAuditTotal);
        return prefix + "/edit";
    }

    /**
     * 修改保存稽查总
     */
    @RequiresPermissions("system:total:edit")
    @Log(title = "稽查总", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TRfidAuditTotal tRfidAuditTotal) {
        return toAjax(tRfidAuditTotalService.updateTRfidAuditTotal(tRfidAuditTotal));
    }

    /**
     * 删除稽查总
     */
    @RequiresPermissions("system:total:remove")
    @Log(title = "稽查总", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(tRfidAuditTotalService.deleteTRfidAuditTotalByIds(ids));
    }


    /**
     * 查看稽查明细
     * @param auditId
     * @param mmap
     * @return
     */
    @RequiresPermissions("system:auditTotal:detail")
    @GetMapping("/detail/{auditId}")
    public String detail(@PathVariable("auditId") Long auditId, ModelMap mmap) {
        TRfidAuditTotal tRfidAuditTotal = tRfidAuditTotalService.selectTRfidAuditTotalById(auditId);
        mmap.put("tRfidAuditTotal", tRfidAuditTotal);
        return prefix + "/detail";
    }
}
